import request from '../../http/request';

export function getCaptchaTypeAndToken(params: any) {
  return request.post(`/admin-api/system/captcha/get`, params);
}

export function verifyCaptcha(params: any) {
  return request.post(`/admin-api/system/captcha/check`, params);
}

export function login(params: any) {
  return request.post(`/user/loginPC`, params);
}

export function logout() {
  return request.post(`/admin-api/system/auth/logout`);
}

export function fetchTenantByName(name: string) {
  return request.get(
    `/admin-api/system/tenant/get-id-by-name?name=${encodeURIComponent(name)}`
  );
}

export function currentUser(accessToken?: string) {
  if (accessToken) {
		// Authorization head should be fulfilled in interceptor.
		return request.get("/user/getDetail", {
			headers: { mrktcoopToken: accessToken },
		});
	}
	return request.get("/user/getDetail");
}

export function getCurrentOrgList() {
  return request.get(`/admin-api/system/user-dept/org/list`);
}
